%%%-------------------------------------------------------------------
%%% @author admin
%%% @copyright (C) 2023, <COMPANY>
%%% @doc
%%%
%%% @end
%%% Created : 06. 五月 2023 15:05
%%%-------------------------------------------------------------------
-module(ets_db).
-author("admin").

-include("db_load.hrl").

%% API
-export([
    init/0
]).


init() ->
    [ets:new(TableName, [named_table])|| TableName<- ?ALL_DB_TABLE],
    ok.

query(multi_hget, TableName, Keys) ->
    lists:flatten([
        case ets:member(TableName, K) andalso ets:lookup(TableName, K) of
            false -> [];
            V -> V
        end||K <- Keys]);
query(_, _, _) -> bad_command.